<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
<%System.out.println(request.getAttribute("msg")); %>
<c:choose>
    <c:when test="${msg=='新增成功' }">
        <script>alert('新增成功')</script>
    </c:when>
    <c:when test="${msg=='新增失败' }">
        <script>alert('新增失败')</script>
    </c:when>
    <c:when test="${msg=='屏蔽成功' }">
        <script>alert('屏蔽成功')</script>
    </c:when>
    <c:when test="${msg=='屏蔽失败' }">
        <script>alert('屏蔽失败')</script>
    </c:when>


</c:choose>

<%
    request.setAttribute("msg","");
%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>评论列表</title>
    <link type="text/css" rel="stylesheet" href="fontsawesome/css/font-awesome.css"/>
    <link type="text/css" rel="stylesheet" href="css/style_index.css"/>
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
    <script src="js/MyAjax.js"></script>
    <style type="text/css">
        .pagination{
            position: relative;
            left: 1400px;
            top: -42px;

        }
        @keyframes fade-in {
            0% {opacity: 0;}/*初始状态 透明度为0*/
            40% {opacity: 0;}/*过渡状态 透明度为0*/
            100% {opacity: 1;}/*结束状态 透明度为1*/
        }
        @-webkit-keyframes fade-in {/*针对webkit内核*/
            0% {opacity: 0;}
            40% {opacity: 0;}
            100% {opacity: 1;}
        }
        body {
            animation: fade-in;/*动画名称*/
            animation-duration: 1.5s;/*动画持续时间*/
            -webkit-animation:fade-in 1.5s;/*针对webkit内核*/
        }
        .m_photo{
        	width:50px;
        	height:50px;
        }
        
        
    </style>
</head>
<body>
<div class="main_box">
    <h2><span></span>评论列表</h2>
    <div class="cont_box">
        <form action="#" method="post" id="staff_form">
            <div class="search_formbox clearfix">
                <button type="button" id="job" class="btn blue_btn" onclick="javascript:goPage(1)">全部评论</button>
            </div>
            <table border="0" cellspacing="0" cellpadding="0" class="table" id="table_box">
                <thead>

                <tr>
                	<th>编号</th>
                    <th>评论商品</th>
                    <th>评论内容</th>
                    <th>评论时间</th>
                    <th>评论人</th>
                    <th width="268">操作</th>
                </tr>
                </thead>
                <tbody id="tbody">

                </tbody>
            </table>
            <div id="pagin" class="pagin">

            </div>
        </form>
    </div>
</div>



<script>


    goPage(1);
    function goPage(cp){
    	var ctx = 'http://<%=request.getServerName() %>:8080/merchaned_photo/';
        ajax("get","pl?flag=findall&cp="+cp,null,function(data){
            //将JSON字符串转为js对象
            data = JSON.parse(data);
            //获取js对象中的集合
            var list = data.list;
            var tabData = "";
            var count = 0;
            for(var i = 0;i<list.length;i++){
                count++;
                tabData +="<tr>"
                tabData +="<th>"+list[i].id+"</th>"
                tabData +="<th>"+list[i].spid+"</th>"
                tabData +="<th>"+list[i].plxx+"</th>"
                tabData +="<th>"+list[i].plsj+"</th>"
                tabData +="<th>"+list[i].plrid+"</th>"
                tabData +="<td>"

                tabData +="<a href='pl?flag=delete&id="+list[i].id+"' class='table_btn table_del del_btn'><i class='fa fa-edit'></i><span>违规屏蔽</span></a>"

                tabData +="</td>"
                tabData += "</tr>"
            }
            //将数据写入到tbody中
            $("tbody").innerHTML = tabData;
            //调用分页列表
            getPageLink(data);
        })
    }

    //生成分页列表的函数
    function getPageLink(data){
        //拼接分页的超链接
        var ul = '<div class="message">共<i class="blue">'+data.totalPage+'</i>页，当前显示第&nbsp;<i class="blue">'+data.currentPage+'&nbsp;</i>页</div>'
        ul += ' <ul class="pagination">';
        if(data.currentPage == 1){
            ul += ' <li class="disabled"><a href="javascript:void(0)"><span class="pagepre"></span></a></li>'
        }else{
            ul += '<li><a href="javascript:goPage('+data.pre+')"><span class="pagepre"></span></a></li>'
        }
        for(var i=1;i<=data.totalPage;i++){
            if(i == data.currentPage){
                ul += '<li class="active"><a href="javascript:goPage('+i+');" style="width:25px;height:28px">'+i+'</a></li>'
            }else{
                ul += '<li><a href="javascript:goPage('+i+');">'+i+'</a></li>'
            }
        }
        if(data.currentPage == data.totalPage){
            ul += '<li class="disabled"><a href="javascript:void(0);"><span class="pagenxt"></span></a></li>'
        }else{
            ul += '<li><a href="javascript:goPage('+data.next+')"><span class="pagenxt"></span></a></li>'
        }
        ul += '</ul>';

        $('pagin').innerHTML = ul;
    }



    function $(id){
        return document.getElementById(id);
    }

</script>
</body>
</html>